package com.longteng.java.web.thread;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by tianqing.wang
 * DATE : 2018/4/22
 * TIME : 上午9:04
 * PROJECT : web-lesson
 * PACKAGE : com.longteng.java.web.thread
 *
 * @author <a href="mailto:celeskyking@163.com">tianqing.wang</a>
 */
public class Worker {


    private ExecutorService executorService;

    private int size;


    public Worker(int size){
        this.size = size;
        this.executorService = Executors.newFixedThreadPool(size);
    }


    public void execute(){
        for(int i=0;i<100;i++){
            executorService.submit(new Task(String.valueOf(i)));
        }
    }


    public int size(){
        return size;
    }



    public static class Task implements Runnable {


        public String name;


        public Task(String name){
            this.name = name;
        }

        @Override
        public void run() {
            System.out.println(name);
        }
    }


}
